/************************************************************
//  Copyright (c)  
//	FileName	  : main.c
//	Function	  : Main Function
//  Instructions  : Contains the MCU initialization function and its H file
//************************************************************
/********************Includes************************************************************************/
#include "SC_Init.h"	// MCU initialization header file, including all firmware library header files
#include "SC_it.h"
#include "..\Drivers\SCDriver_list.h"
#include "..\Drivers\TKDriver\C\TKDriver.h"
#include "..\Apps\bsp_key.h"
#include "..\Apps\multi_timer.h"
#include "..\Apps\app_task.h"
/**************************************Generated by EasyCodeCube*************************************/
//Forbid editing areas between the labels !!!

/*************************************.Generated by EasyCodeCube.************************************/

/*****************************************************************************************************
* Function Name: main
* Description  : This function implements main function.
* Arguments    : None
* Return Value : None
******************************************************************************************************/
uint8_t EE_Add;
uint8_t EE_Data[2];
void main(void)
{	
    /*<Generated by EasyCodeCube begin>*/
    /*<UserCodeStart>*//*<SinOne-Tag><353>*/
    uint32_t temp_touch;
    uint8_t code *eeprom_P=0;
    EA = 0;
    while((EE_Data[0] | EE_Data[1]) != 255 && EE_Add < 128)
    {
        IAPADE = 0x02;
        EE_Data[0] = *(eeprom_P+EE_Add);
        EE_Data[1] = *(eeprom_P+1+EE_Add);
        IAPADE = 0x00;
        EE_Add+=2;
    }
    EA = 1;
    if(EE_Add < 128)
    {
      if(EE_Data[0] > 20)
        Setspeed = 0;
      else Setspeed = 48u*(uint16_t)EE_Data[0];
        
    }else {
        EE_Add = 0;
        Setspeed = 0;
    }
    
    GPIO_WriteHigh(GPIO2,GPIO_PIN_0);
    GPIO_WriteHigh(GPIO2,GPIO_PIN_1);
    GPIO_WriteHigh(GPIO2,GPIO_PIN_2);
    GPIO_WriteHigh(GPIO2,GPIO_PIN_3);
    GPIO_WriteLow(GPIO0,GPIO_PIN_1);
    Button_Config();
    TaskAll_Config();
    /*<UserCodeEnd>*//*<SinOne-Tag><353>*/
    /*<UserCodeStart>*//*<SinOne-Tag><197>*/
    SC_Init();
    /*<UserCodeEnd>*//*<SinOne-Tag><197>*/
    /*<UserCodeStart>*//*<SinOne-Tag><9>*/
    TouchKeyInit();
    /*<UserCodeEnd>*//*<SinOne-Tag><9>*/
    /*<UserCodeStart>*//*<SinOne-Tag><10>*/
    while(1)
    {
        /*<UserCodeStart>*//*<SinOne-Tag><14>*/
        if(SOCAPI_TouchKeyStatus & 0x80)
        {
            /*<UserCodeStart>*//*<SinOne-Tag><22>*/
            SOCAPI_TouchKeyStatus &= 0x7f;
            /*<UserCodeEnd>*//*<SinOne-Tag><22>*/
            /*<UserCodeStart>*//*<SinOne-Tag><18>*/
            temp_touch = TouchKeyScan();
            if((temp_touch & 0x80000000) == 0)
            exKeyValueFlag = temp_touch;
            /*<UserCodeEnd>*//*<SinOne-Tag><18>*/
            /*<UserCodeStart>*//*<SinOne-Tag><35>*/
            
            /*<UserCodeEnd>*//*<SinOne-Tag><35>*/
            /*<UserCodeStart>*//*<SinOne-Tag><36>*/
            TouchKeyRestart();
            /*<UserCodeEnd>*//*<SinOne-Tag><36>*/
        }
        timer_loop();
        /*<UserCodeEnd>*//*<SinOne-Tag><14>*/
    }
    /*<UserCodeEnd>*//*<SinOne-Tag><10>*/
    /*<Generated by EasyCodeCube end>*/
}
